// (c) Copyright 2013-2014 Stephen Gold <sgold@sonic.net>
// Distributed under the terms of the GNU General Public License

/*
 This file is part of the Bats Game.

 The Bats Game is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by the
 Free Software Foundation, either version 3 of the License, or (at your
 option) any later version.

 The Bats Game is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.

 You should have received a copy of the GNU General Public License
 along with the Bats Game.  If not, see <http://www.gnu.org/licenses/>.
 */
package bats.scene;

import java.util.logging.Logger;
import jme3utilities.SimpleControl;

/**
 * A simple control for a spatial in a scene.
 *
 * @author Stephen Gold <sgold@sonic.net>
 */
public abstract class SceneControl
        extends SimpleControl {
    // *************************************************************************
    // constants

    /**
     * message logger for this class
     */
    final private static Logger logger =
            Logger.getLogger(SceneControl.class.getName());
    // *************************************************************************
    // fields
    /**
     * which scene contains the spatial: set by constructor
     */
    final protected SceneNode scene;
    // *************************************************************************
    // constructors

    /**
     * Instantiate an enabled control for a specified scene.
     *
     * @param scene which scene contains the control (not null)
     */
    protected SceneControl(SceneNode scene) {
        super();

        assert scene != null;
        this.scene = scene;

        assert isEnabled();
    }
    // *************************************************************************
    // new methods exposed

    /**
     * Remove the spatial from the scene, along with its children, controls,
     * water features, and lights.
     */
    public void delete() {
        scene.deleteSpatial(spatial, this);
        /*
         * Remove this control: saved for last.
         */
        spatial.removeControl(this);
        assert spatial == null : spatial;
    }
}